@extends('admin.layout')
@section('title','新增视频')
@section('content')
                <div class="app_content_div" id="app_content_div_301Index">
                    <h3>新增视频</h3>
                </div>
                <form action="/adm/video"  enctype="multipart/form-data" class="form-horizontal">
                    {{csrf_field()}}
                    <div class="form-group">
                        <label for="title" class="col-sm-2 control-label"><span style=" color:red;">*</span>标题</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="name" name="name">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="type" class="col-sm-2 control-label"><span style="color:red;">*</span>视频类型</label>
                        <div class="col-sm-10">
                            <label class="radio-inline">
                                <input type="radio" name="type" id="video_type1" value="1" checked> 直播
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="type" id="video_type2" value="0"> 录播
                            </label>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="profile" class="col-sm-2 control-label"><span style="color:red;">*</span>视频简介</label>
                        <div class="col-sm-10">
                            <input type="text" name="profile" id="profile" value="">

                        </div>
                    </div>
                    <div class="form-group">
                        <label for="start_at" class="col-sm-2 control-label"><span style="color:red;">*</span>直播开始时间</label>
                        <div class="col-sm-10">
                            <input type="datetime-local" step="1" class="form-control ui_timepicker" id="start_at" name="start_at">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="end_at" class="col-sm-2 control-label"><span style="color:red;">*</span>直播结束时间</label>
                        <div class="col-sm-10">
                            <input type="datetime-local" step="1" class="form-control ui_timepicker" id="end_at" name="end_at">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="upload_file" class="col-sm-2 control-label"><span style="color:red;">*</span>缩略图</label>
                        <div class="col-sm-10">
                            <input id="thumb" name="thumb" type="file"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="upload_file" class="col-sm-2 control-label"><span style="color:red;">*</span>视频</label>
                        <div class="col-sm-10">
                            <input type="file" class="form-control" id="website" name="website"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="expertlist" class="col-sm-2 control-label"><span style="color:red;">*</span>关联专家</label>
                        <div class="col-sm-10">
                            <select id="expert">
                                @foreach($oExpert as $v)
                                    <option value="{{$v->id}}">姓名:{{$v->name}}
                                        </option>
                                @endforeach
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-10">
                            <button type="button" onclick="create()" class="btn btn-default">确定</button>
                        </div>
                    </div>
                </form>
                <script>

                    function create() {

                        var start = document.getElementById("start_at");
                        var start_at = start.value.replace("T", " ");
                        var end = document.getElementById("end_at");
                        var end_at = end.value.replace("T", " ");

                        var name = $('#name').val();
                        var type = $("[name='type']:checked").eq(0).val();
                        var profile = $('#profile').val();
                        var website = $('#website').val();
                        var expert_id = $('#expert').val();
                        $.ajaxFileUpload({
                            url: '/adm/video',
                            type: 'post',
                            fileElementId:'thumb',
                            fileElementId:'website',
                            dataType: 'json',
                            data: {
                                'name': name,
                                'type': type,
                                'expert_id':expert_id,
                                'start_at': start_at,
                                'end_at': end_at,
                                'profile':profile,
                                '_token': '{{csrf_token()}}'
                            },
                            success: function (data) {
                                if (data.success) {
                                    alert(data.msg);
                                    location.href = '/adm/video';
                                } else {
                                    alert(data.msg);
                                }
                            }
                        });
                    }
                </script>
@endsection
